package com.web;

import com.domain.UserActPlanActivity;
import com.service.userService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
//
/**
 * 展示活动的参加情况
 * 接收 activityShow.jsp 页面的 activityId数据
 * 提交到 userService 的 FindActUser 函数
 * 转发到 /showActUser.jsp 页面进行展示
 */
@WebServlet("/showActUser")
public class showActUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.解决乱码问题
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.接收参数
        String actId = request.getParameter("activityId");
        //3.进行查询
        List<UserActPlanActivity> userAPA = new userService().FindActUser(Integer.parseInt(actId));
        //4.request进行保存
        request.setAttribute("userAPA",userAPA);
        //4.转发到页面进行展示
        request.getRequestDispatcher("/showActUser.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
